package com.wlc.exception;

/**
 * @author 王立朝 wanglichao@champion-credit.com
 * @description 异常
 * @date 2021-06-29 09:40
 */
public class Demo01 {

    public String method01() {
        String str;
        int result = 0;
        try {
            result = 20 / 0;
        } catch (ArithmeticException e) {
            System.out.println("数学异常" + e.getMessage());
            str = e.getMessage();
            return str;
        } finally {
            System.out.println("无论是否发生异常都会在最后执行");
            str = "最后会执行0";
            return str;
        }
        // return "helllo3";
    }

    public void method02() {
        throw new ArithmeticException("抛出一个数学异常");
    }

    public static void main(String[] args) {
        Demo01 demo01 = new Demo01();
        demo01.method02();
    }
}
